import java.util.Arrays;

/**
 * @author wangj881
 * @date 2024-10-14 17:49
 */
public class L34 {
    public static void main(String[] args) {
//        int[] nums = {5, 7, 7, 8, 8, 10};
        int[] nums = {1};
        int target = 1;
        int[] ints = new Solution().searchRange(nums, target);
        System.out.println(Arrays.toString(ints));
    }


    static class Solution {
        public int[] searchRange(int[] nums, int target) {
            int[] result = new int[]{-1, -1};
            int left = 0;
            int right = nums.length - 1;

            while (left <= right) {
                if (nums[left] < target) {
                    left++;
                } else if (nums[left] == target) {
                    result[0] = left;
                    result[1] = left;
                    break;
                } else {
                    break;
                }
            }

            while (left <= right) {
                if (nums[right] > target) {
                    right--;
                } else if (nums[right] == target) {
                    result[1] = right;
                    break;
                } else {
                    break;
                }
            }
            return result;
        }

    }
}
